<?php
/**
 * Created by PhpStorm.
 * User: cape
 * Date: 2017/10/11
 * Time: 12:44
 */

$var1 = "Example variable";
$var2 = "";


function global_reeferences($use_globals){
    global $var1, $var2;
    if (!$use_globals){
        $var2 = & $var1;
    }else{
        $GLOBALS['var2'] = & $var1;
    }
}

global_reeferences(false);
echo "var2 is set to '$var2'\n'"; //var2 is set to ''
global_reeferences(true);
echo "var2 is set to '$var2'\n'";







































